package biolabs.core

abstract class ProgressApprovalResult {
	def approved(): Boolean
	def errorMessage(): String
	def combine(that: ProgressApprovalResult): ProgressApprovalResult
}

object Approved extends ProgressApprovalResult {
	override def approved() = true
	override def errorMessage() = throw new NoSuchElementException("Progress approved, there is no error message")
	override def combine(that: ProgressApprovalResult) = that
}

case class Declined(msg: String) extends ProgressApprovalResult {
	override def approved() = false
	override def errorMessage() = msg
	override def combine(that: ProgressApprovalResult) = that match {
		case Approved => this
		case Declined(thatMsg) => Declined(this.msg + "\n" + thatMsg)
	}
}